import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
// 导入用户认证页面
import UserAuthView from '../views/UserAuthView.vue'
// 导入个人页面
import ProfileView from '../views/ProfileView.vue'
// 导入分类页面
import CategoryView from '../views/CategoryView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView,
    },
    {
      path: '/about',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/AboutView.vue'),
    },
    // 添加用户认证页面路由
    {
      path: '/user-auth',
      name: 'user-auth',
      component: UserAuthView,
    },
    // 添加个人页面路由
    {
      path: '/profile',
      name: 'profile',
      component: ProfileView,
      meta: {
        requiresAuth: true
      }
    },
    // 添加分类页面路由
    {
      path: '/category',
      name: 'category',
      component: CategoryView,
    },
  ],
})

export default router
